<extend name="Common/common"/>

<block name='content'>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 粉丝管理 <span class="c-gray en">&gt;</span> 粉丝列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="text-c">
	 <span class="select-box inline">
		<select name="" class="select">
			<option value="0">全部分类</option>
			<option value="39">后端技术</option><option value="40">前端技术</option><option value="41">管理系统</option>			
		</select>
		</span> 日期范围：
		<input type="text" onfocus="WdatePicker()" id="logmin" class="input-text Wdate" style="width:120px;">
		-
		<input type="text" onfocus="WdatePicker()" id="logmax" class="input-text Wdate" style="width:120px;">
		<input type="text" name="" id="" placeholder=" 资讯名称" style="width:250px" class="input-text">
		<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜资讯</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a class="btn btn-primary radius" data-title="添加博客" data-href="article-add.html" onclick='refreshData()' href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 同步粉丝数据</a></span> <span class="r">共有数据：<strong>{$count}</strong> 条</span> </div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="80">ID</th>
					<th>openid</th>
					<th width="80">昵称</th>
					<th width="80">性别</th>
					<th width="120">地址</th>
					<th width="75">头像</th>
					<th width="75">关注时间</th>
					<th width="75">备注</th>
					<th width="75">标签</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
				<volist name="fans" id="v">
				<tr class="text-c">
					<td>{$v['id']}</td>
					<td>{$v['openid']}</td>
					<td>{$v['nickname']}</td>
					<td><switch name='v.sex'><case value='1'>男</case><case value='2'>女</case><default/>未知</switch></td>
					<td>{$v['country']} {$v['province']} {$v['city']}</td>
					<td><img src='{$v["headimgurl"]}' style="max-height:60px;max-width:60px;"/></td>
					<td>{$v['subscribe_time']|date='Y-m-d',###}</td>
					<td style="cursor:pointer;" onclick='changeRemark(this)'><span>{$v['remark']}</span><input onblur="sendReq(this,'{$v['openid']}')" class='hidden input-text text-c radius' type='text'/></td>
					<td>{$v['tagid_list']|tag_list}</td>
					<td class="f-14 td-manage"> 
					<a style="text-decoration:none" class="ml-5" onclick="article_add('添加博客','{:U("setTag",array('openid'=>$v['openid']))}','','510')" href="javascript:;" title="编辑">设置标签</a> 
					
				</tr>
				</volist>
			</tbody>
			{$show}
		</table>
	</div>
</div>

<script type="text/javascript">
function article_add(title,url,w,h){
	layer_show(title,url,w,h);
}
function changeRemark(obj){
	$(obj).find('span').addClass('hidden');
	$(obj).attr('onclick','');
	$(obj).find('input').removeClass('hidden').val($(obj).find('span').text()).select();
}
function sendReq(obj,openid){
	setTimeout(function (obj){
		$('td').each(function (){
			if($(this).attr('onclick') == ''){
				$(this).attr('onclick','changeRemark(this)');
			}
		});
	},300);
	// 获取备注值
	var remark = $(obj).val();
	
	if(remark == $(obj).prev().text()){
		$(obj).addClass('hidden');
		$(obj).prev().removeClass('hidden');
		
		return;
	}
	
	$.post('{:U("changeRemark")}',{remark:remark,openid:openid},function(data){
		if(data.status == 1){  // 修改成功
			// 修改显示的数据
			$(obj).prev().text($(obj).val());
			
			layer.msg(data.msg,{icon:6,time:1000});
		}else {  // 修改失败
			layer.msg(data.msg,{icon:5,time:1000});
		}
		
		$(obj).addClass('hidden');
		$(obj).prev().removeClass('hidden');
		
	});
}

/*资讯-添加*/
function refreshData(){
	var index = layer.load(2, {shade: [0.5,'#ccc']});
	$.get('{:U("refreshData")}',function(data){
		layer.close(index);
		if(data.status == 1){
			layer.msg(data.msg,{icon:6,time:1000});
			location.reload();
		}else{
			layer.msg(data.msg,{icon:5,time:1000});
		}
	});
}
/*资讯-编辑*/
function article_edit(title,url,id,w,h){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}
/*资讯-删除*/
function article_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '',
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}


</script> 

</block>